import React from 'react';
import { View, Button } from 'react-native';
import ModalUI from './modalUI';
import styles from './styles';

class WaitingModal extends React.Component {
  state = {
    show: false,
    prompt: '正在加载（3秒后消失)...',
  }
  static navigationOptions = {
    title: '模态窗口',
    text: '',
  };
  onButtonClick = (event) => {
    this.setState({
      show: true,
    });
    setTimeout(()=>{
      this.setState({
        show: false,
      });
    }, 3000);
  }

  render() {
    return (
      <View style={{flex:1 , justifyContent: 'center', alignItems: 'center'}}>
          <Button
            title="打开模态窗口"
            onPress={this.onButtonClick}
          />
         <ModalUI show={this.state.show} prompt={this.state.prompt} />
      </View>
    )
  }
}

export default WaitingModal;
